#if !defined(AFX_UVPROPPAGE_H__D166A2D8_96AC_4213_9166_51F4CF2C4ECE__INCLUDED_)
#define AFX_UVPROPPAGE_H__D166A2D8_96AC_4213_9166_51F4CF2C4ECE__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// UvPropPage.h : header file
//

#include "Struct.h"
#include "Label.h"
#include "Separator.h"
#include "ImageST3.h"
#include "ExclusionST2.h"
#include "CHelper.h"
#include "OptionsHelper.h"
#include "boost\shared_ptr.hpp"
#include "gp_uv_rc.h"

/////////////////////////////////////////////////////////////////////////////
// CUvPropPage dialog

class CInclusionDlgOffset;
class CExclusionST2;

// OnUpdate raisers
enum EUVUPDATEEVENT {
	eueUvForceUpdate,
	eueUvImageFront_Changed,
	eueUvImageBack_Changed,
	eueUvAreaFront_Changed,
	eueUvAreaBack_Changed,
	eueUvSecondPageFront_Changed,
	eueUvSecondPageBack_Changed,
	eueUvAreaFront,
	eueUvAreaBack
};

enum EUVSIDE {
	eusFront,
	eusBack
};

enum EUVLOADERROR {
	eleNoErr,
	eleWrongDimension,		// image has wrong dimension
	eleLoadError			// generic load error
};

enum EUVOPTION {
	euoImage,
	euoArea,
	euoSecondPage,
	euoEnd
};


class CUvPropPage : public CPropertyPage
{
	DECLARE_DYNCREATE(CUvPropPage)

typedef vector<CExclusionST2 *> tvExclusionST2;

// Construction
public:
	CUvPropPage();
	~CUvPropPage();

	HANDLE					pfnHandle;//todo_dii
	HANDLE                  hComPropSheet;
	PFNCOMPROPSHEET         pfnComPropSheet;
	PRINTERDEVMODE			*m_lpDM;
	XIDDrvType				DriverType;
//	CUvPropPage				**m_ppPropertyPage;		// parent's pointer (in DDI.cpp)

// Dialog Data
	//{{AFX_DATA(CUvPropPage)
	enum { IDD = IDD_UV_PROP_PAGE };
	CImageST3	m_picImageBack;
	CImageST3	m_picImageFront;
	CExclusionST2	m_picAreaBack;
	CExclusionST2	m_picAreaFront;
	CLabel	m_stBack;
	CLabel	m_stFront;
	CLabel	m_stMethod;
	BOOL	m_lImageFront;
	BOOL	m_lImageBack;
	BOOL	m_lAreaFront;
	BOOL	m_lAreaBack;
	BOOL	m_lSecondPageFront;
	BOOL	m_lSecondPageBack;
	CString	m_strImageFront;
	CString	m_strImageBack;
	int		m_lMacFront;
	int		m_lMacBack;
	//}}AFX_DATA

	CSeparator m_Sep[6];


// Overrides
	// ClassWizard generate virtual function overrides
	//{{AFX_VIRTUAL(CUvPropPage)
	public:
	virtual BOOL OnApply();
	virtual BOOL OnKillActive();
	virtual BOOL OnSetActive();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
private:
	BOOL	m_bUpdateLocked,
			m_bInitialized,
			m_bProhibit_560_570_Features; // by driver type (560, 570)
	bool	m_bBackEnabled;

	DWORD	m_dwPathIndexFront,
			m_dwPathIndexBack,
			m_dwMachineID;

	MGBITMAP *m_pBmpUvImageFront,
			 *m_pBmpUvImageBack,
			 *m_pBmpUvImageFrontDisplay,
			 *m_pBmpUvImageBackDisplay;

	RGBQUAD *pPaletteUv4_;
	BYTE	chroma[ 4 ];

	tvExclusionST2 vpAreaST_;
	int xImage_, yImage_;
	size_t nAreaCountMax_,
		nDPI_;


	// display name of bitmaps (filename without path) are stored in
    // "m_strImage..." variables, full names are stored in these below
	CString	strImageFrontFull_;
	CString	strImageBackFull_;

	CStateController	m_SC;
	CIniPathIndex m_IniPathIndex;

	nsExclusionStatic2::SEXCLUSIONAREAS Areas_[ 1 ][ nsExclusionStatic2::esSides ];	// storage for exclusion areas
	CInclusionDlgOffset *m_pInclusionDlgOffset;

struct SOptionSelector {
	BOOL * pbVar;	// pointer to member variable
	int ControlID;
	EUVUPDATEEVENT Event;
};
	vector<SOptionSelector> vOptionSelector_[ nsExclusionStatic2::esSides ];

	void	Init();
	void	DisplayToDevmod();
	void	DevmodToDisplay();
	void	UpdateFields();
	void	UpdateImages();
	void	UpdateControls( EUVUPDATEEVENT Event );
	void	fitRect( POINT &outer, RECT &inner, const POINT dst );
	bool	browseForBmpFile( CString *pstrImagePath );
	bool setUvFromImageForSide( LPCTSTR pszUvBmpFile, EUVSIDE Side, bool bShowError );
	EUVLOADERROR loadUvFromImage( LPCTSTR pszFileName, MGBITMAP **m_pBmpUvImage, bool bShowError );
	void	PropPageSetResult();
	void	generateNewPathIndexesIfNecessary();

	LRESULT OnUpdateControl(WPARAM wParam, LPARAM lParam);

	void SetCheck(DWORD IDC, BOOL bValue = TRUE);
	BOOL isChecked(DWORD IDC);
	BOOL isEnabled( DWORD IDC );
	void SetEnabledBack();
	void setOrientation();
	void EditArea( CExclusionST2 *pPic, int iPanel, int iSide );
	void setupOptions();
	void selectOption( EUVSIDE Side, EUVOPTION Option, BOOL bEnable );

protected:
	// Generated message map functions
	//{{AFX_MSG(CUvPropPage)
	virtual BOOL OnInitDialog();
	afx_msg void OnCbImageFront();
	afx_msg void OnCbImageBack();
	afx_msg void OnCbAreaFront();
	afx_msg void OnCbAreaBack();
	afx_msg void OnCbSecondPageFront();
	afx_msg void OnCbSecondPageBack();
	afx_msg void OnPbImageFront();
	afx_msg void OnPbImageBack();
	afx_msg void OnPicAreaFront();
	afx_msg void OnPicAreaBack();
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_UVPROPPAGE_H__D166A2D8_96AC_4213_9166_51F4CF2C4ECE__INCLUDED_)
